package model.initialize;

import model.entity.BacSi;
import model.entity.Benh;
import model.entity.BenhAn;
import model.entity.ChungLoai;
import model.entity.HoSoTiemChung;
import model.entity.KhachHang;
import model.entity.PhieuTiemChung;
import model.entity.Vaccine;
import model.entity.VatNuoi;
import org.hibernate.Hibernate;

public class Initialize {
    public static void initializePhieuTiemChung(PhieuTiemChung phieuTiemChung){
        Hibernate.initialize(phieuTiemChung);
        if(phieuTiemChung.getHoSoTiemChung() != null)
            Hibernate.initialize(phieuTiemChung.getHoSoTiemChung());
        if(phieuTiemChung.getVaccine() != null)
            initializeVaccine(phieuTiemChung.getVaccine());
    }
    public static void initializeVaccine(Vaccine vaccine){
        if(vaccine.getNhaCungCap() != null)
            Hibernate.initialize(vaccine.getNhaCungCap());
        if(vaccine.getGia() != null)
            Hibernate.initialize(vaccine.getGia());
        Hibernate.initialize(vaccine);
    }
    public static void initializeVatNuoi(VatNuoi vatNuoi){
        if(vatNuoi.getChungLoai() != null){
            initializeChungLoai(vatNuoi.getChungLoai());
        }
        if(vatNuoi.getKhachHang() != null){
            initializeKhachHang(vatNuoi.getKhachHang());
        }
        Hibernate.initialize(vatNuoi);
    }
    public static void initializeKhachHang(KhachHang khachHang){
        if(khachHang.getBacSi() != null){
            initializeBacSi(khachHang.getBacSi());
        }
        Hibernate.initialize(khachHang);
    }

    public static void initializeBacSi(BacSi bacSi) {
        if(bacSi.getAdmin() != null){
            Hibernate.initialize(bacSi.getAdmin());
        }
        Hibernate.initialize(bacSi);
    }

    public static void initializeChungLoai(ChungLoai chungLoai) {
        if(chungLoai.getLoai() != null){
            Hibernate.initialize(chungLoai.getLoai());
        }
        Hibernate.initialize(chungLoai);
    }
    public static void initializeHoSoTiemChung(HoSoTiemChung hoSoTiemChung){
        if(hoSoTiemChung.getVatNuoi() != null){
             initializeVatNuoi(hoSoTiemChung.getVatNuoi());
        }
        Hibernate.initialize(hoSoTiemChung);
    }
    public static void initializeBenhAn(BenhAn benhAn){
        if(benhAn.getBenh() != null)
            initializeBenh(benhAn.getBenh());
        if(benhAn.getVatNuoi() != null)
            initializeVatNuoi(benhAn.getVatNuoi());
        Hibernate.initialize(benhAn);
    }

    public static void initializeBenh(Benh benh) {
        Hibernate.initialize(benh);
    }
}
